$(document).ready(function(){
    // 对于发布房源，只有认证后的用户才可以，所以先判断用户的实名认证状态
    $.get("/api/v1.0/user/auth", function (resp) {
        if (resp.errno == "0") {
            // 如果用户已实名认证,那么就去请求之前发布的房源
            $.get("/api/v1.0/houses/landlord", function (resp) {
                if ("0" == resp.errno) {
                    $("#houses-list").html(template("houses-list-tmpl", {"houses":resp.data}));
                    $("#houses-list").show();
                }else if (resp.errno == "4101") {
                    location.href = "/login.html";
                }else {
                    alert(resp.errmsg);
                }
            });
        }else if (resp.errno == "4101") {
            location.href = "/login.html";
        }else {
            $(".auth-warn").show();
            alert(resp.errmsg)
        }
    })
});
